package com.infovane.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.infovane.dao.ArticleDao;

public class ArticleDaoImpl extends HibernateDaoSupport implements ArticleDao{
	
	/**
	 * 根据关键字查询资讯信息
	 * @param hql,keywords
	 * @return List
	 * */
	public List query(final String hql,final String keywords) {
		List list=this.getHibernateTemplate().executeFind(new HibernateCallback(){

			public Object doInHibernate(Session session)
					throws HibernateException, SQLException {
				Query query=session.createQuery(hql);
				query.setString(0,keywords);
				query.setString(1,keywords);
				query.setString(2,keywords);
				query.setString(3,keywords);
				query.setString(4,keywords);
				query.setString(5,keywords);
				query.setString(6,keywords);
				List list=query.list();
				logger.info("query successful!");
				return list;
			}
		});
		return list;
	}

}
